<template>
  <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close"
    :append-to-body="true">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-form-item label="仓库名称">
        <el-input v-model.trim="form.cangkumc" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="仓库面积(㎡)">
        <el-input v-model.trim="form.cangkumj" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="仓库容积(m³)">
        <el-input v-model.trim="form.cangkurj" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="建设时长">
        <el-input v-model.trim="form.jianshesc" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="长(m)">
        <el-input v-model.trim="form.chang" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="宽(m)">
        <el-input v-model.trim="form.kuan" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="高(m)">
        <el-input v-model.trim="form.gao" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="作业人数">
        <el-input v-model.trim="form.zuoyers" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { addKufang, updateKufang, getKufangOne } from '@/api/cangkujichu'

export default {
  name: 'WarehouseManagement',
  data() {
    return {
      form: {

      },
      rules: {},
      title: '',
      dialogFormVisible: false,
    }
  },
  created() { },
  methods: {
    showEdit(row) {
      if (!row) {
        this.title = '新增'
      } else {
        this.title = '编辑'

        this.form = Object.assign({}, row)
      }
      this.dialogFormVisible = true
    },
    close() {
      this.$refs['form'].resetFields()
      this.form = this.$options.data().form
      this.dialogFormVisible = false
    },
    save() {
      this.$refs['form'].validate(async (valid) => {
        if (valid) {
          let res = null;
          if (this.title == '新增') {
            res = await addKufang(this.form)
          } else {
            res = await updateKufang(this.form)
          }
          this.$baseMessage(res.msg, 'success')
          this.$emit('fetch-data')
          this.close()
        } else {
          return false
        }
      })
    },
  },
}
</script>
<style lang="scss" scoped>
.el-select--small {
  width: 100%;
}
</style>
